<?php

declare(strict_types=1);

namespace app\service\system;

use app\service\system\file\FileManage;

class UploadService
{
    /**
     * 文件上传
     * @param File $file
     * @param string $type
     */
    public function upload($file, string $type): array
    {
        $manage = new FileManage();
        if (!$file->getOriginalName()) {
            tips('文件上传失败');
        }
        if ($file->getSize() > $manage->maxSize()) {
            tips('文件大小不能超过' . $manage->maxSize(false));
        }
        return $manage->upload($file, $type);
    }
}
